<template>
    <div id="Boxs">
        <nav class="nav">
            <p v-for="(v) in this.$store.state.seach.seach" v-bind:key="v.id">
                <img :src="v.img" alt="">
                <span>{{v.name}}</span>
            </p>
        </nav>
    </div>
</template>

<script>
    export default {
        name: "fenqu",
        created () {
            //在页面加载时读取localStorage里的状态信息
            if (localStorage.getItem("data") ) {
                //replaceState替换数据 Object.assign合并对象
                this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(localStorage.getItem("data"))))
            }
            //在页面刷新时将vuex里的信息保存到localStorage里
            window.addEventListener("beforeunload",()=>{
                localStorage.setItem("data",JSON.stringify(this.$store.state))
            })
        },

    }
</script>

<style lang="scss">
    #Boxs{
        width: 100%;
        height: 100%;
        background-color: #ffffff;
        padding-bottom: 0.6rem;
        .nav{
            height: 100%;
            border-width: 0;
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
            p{
                width: 1.2rem;
                flex-shrink: 0;
                margin-top: 0.3rem;
                margin-bottom: 0.1rem;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: flex-start;
                img{
                    display: block;
                    width: 0.48rem;
                }
                span{
                    display: block;
                    margin-top: 0.06rem;
                    font-size: 0.14rem;
                    color: #353535;
                }
            }
        }
    }
</style>